package cc.yugu.yhdw.webserver.web.controller.security.basic;

import cc.yugu.yhdw.common.annotation.ViewModel;

import cc.yugu.yhdw.common.domain.basic.Feedback;
import cc.yugu.yhdw.common.entity.json.ExtResult;
import cc.yugu.yhdw.common.entity.json.PageResult;
import cc.yugu.yhdw.webserver.constant.AppConstEnum;
import cc.yugu.yhdw.webserver.service.basic.FeedbackService;
import cc.yugu.yhdw.webserver.web.controller.security.SecurityController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 用户意见反馈控制器
 * 
 * @Date:Created in 2018/7/23 14:53
 * @Author:
 * @Modified By: zjn 2018/7/23 14:53
 */ 
@RequestMapping(value = "/security/basic/feedback")
@Controller
public class FeedbackController extends SecurityController {

    @Autowired
    FeedbackService feedbackService;

    @RequestMapping("index.htm")
    public void index(Model model) {
        model.addAttribute(MENU_CODE_NAME, AppConstEnum.Menu.MENU_06_02.getValue());
    }
    /**
    * 分页查询用户反馈信息
    * 
    * @Param: [search]
    * @Return: cc.yugu.yhdw.common.entity.json.PageResult
    * @Author By: zjn 2018/7/23  14:53
    */ 
    @RequestMapping("page.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public PageResult page(Feedback search) {
        return PageResult.successResult(feedbackService.findPage(search));
    }
    /**
    * 页面点击查看，弹出用户反馈信息页面
    * 
    * @Param: [id, model]
    * @Return: java.lang.String
    * @Author By: zjn 2018/7/23  14:54
    */ 
    @ViewModel(ViewModel.INNER_PAGE)
    @RequestMapping("view.htm")
    public String view(int id, Model model) {
        Feedback feedback = feedbackService.find(id);
        if(feedback == null) {
            return SEGMENT_RECORD_NOT_FOUND;
        }
        model.addAttribute("entity", feedback);
        return "/security/basic/feedback/view";
    }
    /**
    * 删除
    * 
    * @Param: [id]
    * @Return: cc.yugu.yhdw.common.entity.json.ExtResult
    * @Author By: zjn 2018/7/23  14:54
    */ 
    @RequestMapping("delete.htm")
    @ViewModel(ViewModel.JSON)
    @ResponseBody
    public ExtResult delete(int id) {
        feedbackService.delete(id);
        return ExtResult.successResult();
    }


}
